<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>找回密码/重置密码</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="keywords" content="fly,layui,前端社区">
  <meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
  <script type="text/javascript" src="../static/jquery-3.2.1.min.js"></script>
  <link rel="stylesheet" href="../static/res/layui/css/layui.css">
  <link rel="stylesheet" href="../static/res/css/global.css">
</head>
<body>

<jsp:include page="fly-head.jsp"></jsp:include>

<div class="layui-container fly-marginTop">
  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title">
        <li class="layui-this">找回密码</li>
      </ul>
      <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding: 20px 0;">
        <div class="layui-tab-item layui-show" style="text-align: center">
            <div style="margin: 0 auto;height: 120px">
            <img src="/images/step1.png">
            </div>
          <div class="layui-form layui-form-pane" style="width: 450px;margin: 0 auto">
            <form>

              <div class="layui-form-item">
                <label for="L_username" class="layui-form-label">账号</label>
                <div class="layui-input-inline">
                  <input type="text" id="L_username" name="phone" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <label for="L_vercode" class="layui-form-label">验证码</label>
                <div class="layui-input-inline">
                  <input type="text" id="L_vercode" name="vercode" required lay-verify="required" placeholder="请输入验证码" autocomplete="off" class="layui-input">
                </div>
                <div>
                  <!-- 验证码 -->
                  <img id="img" style="float: left" src="${ctx}/authImage"/>
                  <a href='#' onclick="javascript:changeImg()" style="color:white;">
                    <label style="color:black;float: left">换一张</label></a>
                </div>
                </div>
              <div class="layui-form-item">
                <button class="layui-btn" alert="1" lay-filter="*" lay-submit onclick="nextStep2();return false">提交</button>
              </div>
            </form>
          </div>
          
        </div>
      </div>
    </div>
  </div>
</div>
<jsp:include page="fly-footer.jsp"></jsp:include>

<script src="../static/res/layui/layui.js"></script>
<script>
    function changeImg() {
        var img = document.getElementById("img");
        img.src = "${ctx}/authImage?date=" + new Date();
        ;
    }

    function nextStep2() {

        if ($("#L_username").val() == "") {
            alert("手机号不能为空");
            $("#L_username").focus();
            return false;
        }
        if ($("#L_vercode").val() == "") {
            alert("验证码不能为空");
            $("#L_vercode").focus();
            return false;
        }
//获取用户名密码 验证码
        var username = document.getElementById("L_username").value;
        var vercode = document.getElementById("L_vercode").value.toLowerCase();
        $.ajax({
            url: "/userAdmin/AdminForgetPhoneKey",
            type: "post",
            datatype: "json",
            data: {
                'username': username,
                'vercode': vercode
            },
            success: function (data, state) {
                  if (data.msg=="账号验证码正确"){
                      window.location.href="/admin/adminForgetSet2.jsp?username="+username;
                  } if (data.msg=="验证码不正确"){
                    alert(data.msg);
                }
                if (data.msg=="该账号未注册"){
                    alert(data.msg);
                }
            },
            error: function () {
                alert("服务器出错，请重新输入");
                changeImg();
            }
        })
    }

</script>

</body>
</html>